{% extends "base.html" %}

{% block head %}
  <script type="text/javascript">
  function checkForm(theForm) {
    var filePath = theForm.file.value;
    if (filePath == '') {
      alert('上传文件不能为空！');
      return false;
    }
    theForm.submitButton.disabled = true;
    theForm.submitButton.value = "上传中，请稍候......";
    theForm.fileName.value = filePath.substr(filePath.lastIndexOf('\\') + 1);
    return true;
  }

  </script>
{% endblock %}

{% block body %}
    <form method="post" enctype="multipart/form-data" onSubmit="return checkForm(this)">
      <input type="hidden" name="fileName"/>
      <div>上传文件(受GAE限制，最大只能1M哦)：</div>
      <div><input type="file" name="file" size="40"/></div>
      <div><p><input name="submitButton" type="submit" value=" 上 传 "/></p></div>
      <div>上传买家历史记录：</div>
      {% if buyers %}
          <table width="100%" border="1">
              <tr>
                  <td align="center">Contact Person</td>
                  <td align="center">Company Name</td>
                  <td align="center">Country/Region</td>
              </tr>
            {% for buyer in buyers %}
              <tr>
                  <td align="left"><a href="/showbuyer?key={{buyer.key}}">{{buyer.contactName}}</a></td>
                  <td>{{ buyer.companyName }}</td>
                  <td>{{buyer.area}} - {{buyer.country}}</td>
              </tr>
            {% endfor %}
          </table>
      {% endif %}
    </form>
{% endblock %}
